package org.dei.perla.aggregates;

import java.util.Iterator;
import java.util.List;

import org.dei.perla.parser.expressions.ConstantFloat;

public class SampleMean implements AggregationOperator {

	@Override
	public ConstantFloat doOperation(ConstantFloat[] sample) {
		double mean = 0;
        int len = sample.length;
        mean = new SampleSum().doOperation(sample).getValueFloat();
        mean /= (double)len;
        return new ConstantFloat(mean);
	}

	@Override
	public ConstantFloat doOperation(List<ConstantFloat> sample) {
		double mean = 0;
        int len = sample.size();
        mean = new SampleSum().doOperation(sample).getValueFloat();
        mean /= (double)len;
        return new ConstantFloat(mean);
	}

}
